package com.blink.optimize.apis.calculate;

import org.junit.jupiter.api.Test;

/**
 * <ClassName>TestCalculate</ClassName>
 * <Description></Description>
 *
 * @Author liuxianzhao
 * @Date 2018年01月06日 12:40
 */
public class TestCalculate {
    /**
     * 普通运算
     */
    @Test
    public void testCalculate1() {
        long start1 = System.nanoTime();
        long a = 1000;
        for (int i = 0; i < 1000000000; i++) {
            a *= 2;
            a /= 2;
        }
        System.out.println(a);
        System.out.println(System.nanoTime() - start1);
    }

    /**
     * 位运算
     */
    @Test
    public void testCalculate2() {
        long start2 = System.nanoTime();
        long b = 1000;
        for (int i = 0; i < 1000000000; i++) {
            b <<= 1;
            b >>= 1;
        }
        System.out.println(b);
        System.out.println(System.nanoTime() - start2);
    }
}
